package dynasty_info.Task;

import dynasty_info.Utils.ParseDetailedUrl;

import java.util.Timer;

public class Task {
    public static void main(String[] args) {
        //创建诗歌字符串数组
        String[] dynasties = {"先秦诗歌", "汉朝诗歌", "唐诗", "隋唐五代诗", "宋诗", "元代诗", "明代诗", "清代诗"};
        //利用for循环连接百度百科链接
        for (int i = 0; i < dynasties.length; i++) {
            String url = "https://baike.baidu.com/item/" +dynasties[i];
            System.out.println("正在爬取" + url + "...");
            /* 获取当前系统时间*/
            long startTime =  System.currentTimeMillis();
            try {
                new ParseDetailedUrl().parseUrl(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(url + "爬取完成！");
            /* 获取当前的系统时间，与初始时间相减就是程序运行的毫秒数*/
            long endTime =  System.currentTimeMillis();
            long usedTime = endTime-startTime;
            System.out.println("共耗时：" + usedTime + "毫秒!");
            System.out.println("=============================================================");
        }
    }
}
